package com.ljl.springbootdemo.controller;

import com.ljl.springbootdemo.pojo.User;
import com.ljl.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService service;

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public  void save(User user){

        service.save(user);
    }
    @GetMapping(value = "/find/all")
    public List<User> findAll(){
        System.out.println("到controller层");
        List<User> list = service.findAll();

        return list;
    }
}
